package com.toocms.jinjuhang.widget.video

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.SeekBar
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer

class MyGSYVideoPlayer : StandardGSYVideoPlayer {
    var onProgressListener: ((progress: Long, count: Long) -> Unit)? = null


    constructor(context: Context?, fullFlag: Boolean?) : super(context, fullFlag)
    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)

    fun showBottomContainer(isShow: Boolean) {
        mBottomContainer.visibility = if (isShow) View.VISIBLE else View.GONE
        mProgressBar.visibility = if (isShow) View.VISIBLE else View.GONE
        mCurrentTimeTextView.visibility = if (isShow) View.VISIBLE else View.GONE
        mTotalTimeTextView.visibility = if (isShow) View.VISIBLE else View.GONE
    }

    override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
        super.onProgressChanged(seekBar, progress, fromUser)
        onProgressListener?.invoke(progress * duration / (seekBar?.max?:100),duration)
    }

}